//
//  HJJRadioDetailCell.m
//  Pianke
//
//  Created by 黄俊杰 on 15/12/26.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "HJJRadioDetailCell.h"

@implementation HJJRadioDetailCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews{
    
    self.coverimgImageView = [[UIImageView alloc] init];
    self.coverimgImageView.backgroundColor = [UIColor grayColor];
        self.coverimgImageView.layer.masksToBounds = YES;
        self.coverimgImageView.layer.cornerRadius = 30;
    [self.contentView addSubview:self.coverimgImageView];
    [self.coverimgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(4);
        make.right.mas_equalTo(self.coverimgImageView.mas_left).offset(75);
        make.bottom.mas_equalTo(self.coverimgImageView.mas_top).offset(60);
    }];
    
//    self.isNewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 * SCREEN_WIDTH, 10 * SCREEN_HEIGHT, 25 * SCREEN_WIDTH, 25 * SCREEN_HEIGHT)];
//    self.isNewImageView.hidden = YES;
//    [self.contentView addSubview:self.isNewImageView];
    
    self.musicVisitImageView = [[UIImageView alloc] init];
    self.musicVisitImageView.image = [UIImage imageNamed:@"umeng_fb_audio_play_default@2x.png"];
    [self.contentView addSubview:self.musicVisitImageView];
    [self.musicVisitImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.coverimgImageView.mas_right).offset(5);
        make.right.mas_equalTo(self.musicVisitImageView.mas_left).offset(7);
        make.bottom.mas_equalTo(self.coverimgImageView.mas_bottom).offset(-7);
        make.top.mas_equalTo(self.musicVisitImageView.mas_bottom).offset(-10);
    }];
    
    
    self.musicVisitLabel = [[UILabel alloc] init];
    self.musicVisitLabel.font = SMALLFONT;
    self.musicVisitLabel.textColor = BLUECOLOR;
    [self.contentView addSubview:self.musicVisitLabel];
    [self.musicVisitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.musicVisitImageView.mas_right).offset(5);
        make.right.mas_equalTo(self.musicVisitLabel.mas_left).offset(60);
        make.bottom.mas_equalTo(self.coverimgImageView.mas_bottom).offset(-4);
        make.top.mas_equalTo(self.musicVisitImageView.mas_bottom).offset(-15);
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.textColor = GRAYCOLOR;
    self.titleLabel.font = MIDDLEFONT;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.coverimgImageView.mas_right).offset(5);
        make.right.mas_equalTo(self.titleLabel.mas_left).offset(150);
        make.top.mas_equalTo(self.coverimgImageView.mas_top).offset(4);
        make.bottom.mas_equalTo(self.titleLabel.mas_top).offset(25);
    }];
    
    self.playImageView = [[UIImageView alloc] init];
    self.playImageView.image = [UIImage imageNamed:@"play1.png"];
    [self.contentView addSubview:self.playImageView];
    [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(27);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
}

-(void)sendModel:(HJJRadioRootModel *)model{

//    NSLog(@"%@",model.coverimg);
    NSURL *url = [NSURL URLWithString:model.coverimg];
    
    [self.coverimgImageView sd_setImageWithURL:url placeholderImage:nil];

    
    self.titleLabel.text = model.title;
    self.musicVisitLabel.text = model.musicVisit;
    
//    if (model.isnew) {
//        self.isNewImageView.hidden = NO;
//        self.isNewImageView.image = [UIImage imageNamed:@"iconfont-tubiao103"];
//    }

}


@end
